#!/bin/sh
#
# chkconfig: - 88 12
# description:  GLPI Agent
# processname: glpi-agent
# config: /etc/sysconfig/glpi-agent
# pidfile: /var/run/glpi-agent.pid
### BEGIN INIT INFO
# Provides: glpi-agent
# Required-Start: $remote_fs $network $named $syslog
# Required-Stop: $remote_fs $network $named $syslog
# Default-Start: 3 5
# Default-Stop: 0 1 6
# Short-Description: GLPI agent
# Description: GLPI agent
### END INIT INFO

# source function library
. /etc/rc.d/init.d/functions

desc="GLPI Agent"
prog=glpi-agent
lockfile=/var/lock/subsys/$prog
pidfile=/var/run/$prog.pid

if [ -r /etc/sysconfig/glpi-agent ]; then
    . /etc/sysconfig/glpi-agent
fi

start() {
    echo -n "Starting $prog: "
    daemon glpi-agent --daemon $OPTIONS --pidfile $pidfile 2>/dev/null
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && touch $lockfile
}

stop() {
    echo -n "Stopping $prog: "
    killproc $prog
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && rm -f $lockfile
}

case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    status)
        status $prog
        ;;
    restart|reload|force-reload)
        stop
        start
        ;;
    condrestart)
        if [ -f $lockfile ]; then
            stop
            start
        fi
        ;;
    *)
        echo "Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
        exit 1
        ;;
esac

